\(\int x \tan ^2(a+i \log (x)) \, dx\) [145]

   Optimal result
   Rubi [A] (verified)
   Mathematica [B] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [B] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 13, antiderivative size = 51 \[ \int x \tan ^2(a+i \log (x)) \, dx=-\frac {x^2}{2}+\frac {2 e^{4 i a}}{e^{2 i a}+x^2}+2 e^{2 i a} \log \left (e^{2 i a}+x^2\right ) \]

[Out]

-1/2*x^2+2*exp(4*I*a)/(exp(2*I*a)+x^2)+2*exp(2*I*a)*ln(exp(2*I*a)+x^2)

Rubi [A] (verified)

Time = 0.07 (sec) , antiderivative size = 51, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.308, Rules used = {4591, 456, 455, 45} \[ \int x \tan ^2(a+i \log (x)) \, dx=\frac {2 e^{4 i a}}{x^2+e^{2 i a}}+2 e^{2 i a} \log \left (x^2+e^{2 i a}\right )-\frac {x^2}{2} \]

[In]

Int[x*Tan[a + I*Log[x]]^2,x]

[Out]

-1/2*x^2 + (2*E^((4*I)*a))/(E^((2*I)*a) + x^2) + 2*E^((2*I)*a)*Log[E^((2*I)*a) + x^2]

Rule 45

Int[((a_.) + (b_.)*(x_))^(m_.)*((c_.) + (d_.)*(x_))^(n_.), x_Symbol] :> Int[ExpandIntegrand[(a + b*x)^m*(c + d
*x)^n, x], x] /; FreeQ[{a, b, c, d, n}, x] && NeQ[b*c - a*d, 0] && IGtQ[m, 0] && ( !IntegerQ[n] || (EqQ[c, 0]
&& LeQ[7*m + 4*n + 4, 0]) || LtQ[9*m + 5*(n + 1), 0] || GtQ[m + n + 2, 0])

Rule 455

Int[(x_)^(m_.)*((a_) + (b_.)*(x_)^(n_))^(p_.)*((c_) + (d_.)*(x_)^(n_))^(q_.), x_Symbol] :> Dist[1/n, Subst[Int
[(a + b*x)^p*(c + d*x)^q, x], x, x^n], x] /; FreeQ[{a, b, c, d, m, n, p, q}, x] && NeQ[b*c - a*d, 0] && EqQ[m
- n + 1, 0]

Rule 456

Int[(x_)^(m_.)*((a_) + (b_.)*(x_)^(n_))^(p_.)*((c_) + (d_.)*(x_)^(n_))^(q_.), x_Symbol] :> Int[x^(m + n*(p + q
))*(b + a/x^n)^p*(d + c/x^n)^q, x] /; FreeQ[{a, b, c, d, m, n}, x] && NeQ[b*c - a*d, 0] && IntegersQ[p, q] &&
NegQ[n]

Rule 4591

Int[((e_.)*(x_))^(m_.)*Tan[((a_.) + Log[x_]*(b_.))*(d_.)]^(p_.), x_Symbol] :> Int[(e*x)^m*((I - I*E^(2*I*a*d)*
x^(2*I*b*d))/(1 + E^(2*I*a*d)*x^(2*I*b*d)))^p, x] /; FreeQ[{a, b, d, e, m, p}, x]

Rubi steps \begin{align*} \text {integral}& = \int \frac {\left (i-\frac {i e^{2 i a}}{x^2}\right )^2 x}{\left (1+\frac {e^{2 i a}}{x^2}\right )^2} \, dx \\ & = \int \frac {x \left (-i e^{2 i a}+i x^2\right )^2}{\left (e^{2 i a}+x^2\right )^2} \, dx \\ & = \frac {1}{2} \text {Subst}\left (\int \frac {\left (-i e^{2 i a}+i x\right )^2}{\left (e^{2 i a}+x\right )^2} \, dx,x,x^2\right ) \\ & = \frac {1}{2} \text {Subst}\left (\int \left (-1-\frac {4 e^{4 i a}}{\left (e^{2 i a}+x\right )^2}+\frac {4 e^{2 i a}}{e^{2 i a}+x}\right ) \, dx,x,x^2\right ) \\ & = -\frac {x^2}{2}+\frac {2 e^{4 i a}}{e^{2 i a}+x^2}+2 e^{2 i a} \log \left (e^{2 i a}+x^2\right ) \\ \end{align*}

Mathematica [B] (verified)

Both result and optimal contain complex but leaf count is larger than twice the leaf count of optimal. \(135\) vs. \(2(51)=102\).

Time = 0.09 (sec) , antiderivative size = 135, normalized size of antiderivative = 2.65 \[ \int x \tan ^2(a+i \log (x)) \, dx=-\frac {x^2}{2}+2 i \arctan \left (\frac {\left (1+x^2\right ) \cot (a)}{-1+x^2}\right ) \cos (2 a)+\cos (2 a) \log \left (1+x^4+2 x^2 \cos (2 a)\right )-2 \arctan \left (\frac {\left (1+x^2\right ) \cot (a)}{-1+x^2}\right ) \sin (2 a)+i \log \left (1+x^4+2 x^2 \cos (2 a)\right ) \sin (2 a)+\frac {2 \cos (3 a)+2 i \sin (3 a)}{\left (1+x^2\right ) \cos (a)-i \left (-1+x^2\right ) \sin (a)} \]

[In]

Integrate[x*Tan[a + I*Log[x]]^2,x]

[Out]

-1/2*x^2 + (2*I)*ArcTan[((1 + x^2)*Cot[a])/(-1 + x^2)]*Cos[2*a] + Cos[2*a]*Log[1 + x^4 + 2*x^2*Cos[2*a]] - 2*A
rcTan[((1 + x^2)*Cot[a])/(-1 + x^2)]*Sin[2*a] + I*Log[1 + x^4 + 2*x^2*Cos[2*a]]*Sin[2*a] + (2*Cos[3*a] + (2*I)
*Sin[3*a])/((1 + x^2)*Cos[a] - I*(-1 + x^2)*Sin[a])

Maple [A] (verified)

Time = 1.36 (sec) , antiderivative size = 42, normalized size of antiderivative = 0.82

method result size
risch \(-\frac {5 x^{2}}{2}+\frac {2 x^{2}}{1+\frac {{\mathrm e}^{2 i a}}{x^{2}}}+2 \,{\mathrm e}^{2 i a} \ln \left ({\mathrm e}^{2 i a}+x^{2}\right )\) \(42\)

[In]

int(x*tan(a+I*ln(x))^2,x,method=_RETURNVERBOSE)

[Out]

-5/2*x^2+2*x^2/(1+exp(2*I*a)/x^2)+2*exp(2*I*a)*ln(exp(2*I*a)+x^2)

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 54, normalized size of antiderivative = 1.06 \[ \int x \tan ^2(a+i \log (x)) \, dx=-\frac {x^{4} + x^{2} e^{\left (2 i \, a\right )} - 4 \, {\left (x^{2} e^{\left (2 i \, a\right )} + e^{\left (4 i \, a\right )}\right )} \log \left (x^{2} + e^{\left (2 i \, a\right )}\right ) - 4 \, e^{\left (4 i \, a\right )}}{2 \, {\left (x^{2} + e^{\left (2 i \, a\right )}\right )}} \]

[In]

integrate(x*tan(a+I*log(x))^2,x, algorithm="fricas")

[Out]

-1/2*(x^4 + x^2*e^(2*I*a) - 4*(x^2*e^(2*I*a) + e^(4*I*a))*log(x^2 + e^(2*I*a)) - 4*e^(4*I*a))/(x^2 + e^(2*I*a)
)

Sympy [A] (verification not implemented)

Time = 0.15 (sec) , antiderivative size = 42, normalized size of antiderivative = 0.82 \[ \int x \tan ^2(a+i \log (x)) \, dx=- \frac {x^{2}}{2} + 2 e^{2 i a} \log {\left (x^{2} + e^{2 i a} \right )} + \frac {2 e^{4 i a}}{x^{2} + e^{2 i a}} \]

[In]

integrate(x*tan(a+I*ln(x))**2,x)

[Out]

-x**2/2 + 2*exp(2*I*a)*log(x**2 + exp(2*I*a)) + 2*exp(4*I*a)/(x**2 + exp(2*I*a))

Maxima [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 185 vs. \(2 (37) = 74\).

Time = 0.21 (sec) , antiderivative size = 185, normalized size of antiderivative = 3.63 \[ \int x \tan ^2(a+i \log (x)) \, dx=-\frac {x^{4} + {\left (4 \, {\left (-i \, \cos \left (2 \, a\right ) + \sin \left (2 \, a\right )\right )} \arctan \left (\sin \left (2 \, a\right ), x^{2} + \cos \left (2 \, a\right )\right ) + \cos \left (2 \, a\right ) + i \, \sin \left (2 \, a\right )\right )} x^{2} + 4 \, {\left (-i \, \cos \left (2 \, a\right )^{2} + 2 \, \cos \left (2 \, a\right ) \sin \left (2 \, a\right ) + i \, \sin \left (2 \, a\right )^{2}\right )} \arctan \left (\sin \left (2 \, a\right ), x^{2} + \cos \left (2 \, a\right )\right ) - 2 \, {\left (x^{2} {\left (\cos \left (2 \, a\right ) + i \, \sin \left (2 \, a\right )\right )} + \cos \left (2 \, a\right )^{2} + 2 i \, \cos \left (2 \, a\right ) \sin \left (2 \, a\right ) - \sin \left (2 \, a\right )^{2}\right )} \log \left (x^{4} + 2 \, x^{2} \cos \left (2 \, a\right ) + \cos \left (2 \, a\right )^{2} + \sin \left (2 \, a\right )^{2}\right ) - 4 \, \cos \left (4 \, a\right ) - 4 i \, \sin \left (4 \, a\right )}{2 \, {\left (x^{2} + \cos \left (2 \, a\right ) + i \, \sin \left (2 \, a\right )\right )}} \]

[In]

integrate(x*tan(a+I*log(x))^2,x, algorithm="maxima")

[Out]

-1/2*(x^4 + (4*(-I*cos(2*a) + sin(2*a))*arctan2(sin(2*a), x^2 + cos(2*a)) + cos(2*a) + I*sin(2*a))*x^2 + 4*(-I
*cos(2*a)^2 + 2*cos(2*a)*sin(2*a) + I*sin(2*a)^2)*arctan2(sin(2*a), x^2 + cos(2*a)) - 2*(x^2*(cos(2*a) + I*sin
(2*a)) + cos(2*a)^2 + 2*I*cos(2*a)*sin(2*a) - sin(2*a)^2)*log(x^4 + 2*x^2*cos(2*a) + cos(2*a)^2 + sin(2*a)^2)
- 4*cos(4*a) - 4*I*sin(4*a))/(x^2 + cos(2*a) + I*sin(2*a))

Giac [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 221 vs. \(2 (37) = 74\).

Time = 0.46 (sec) , antiderivative size = 221, normalized size of antiderivative = 4.33 \[ \int x \tan ^2(a+i \log (x)) \, dx=-\frac {x^{4}}{2 \, {\left (x^{2} + \frac {e^{\left (4 i \, a\right )}}{x^{2}} + 2 \, e^{\left (2 i \, a\right )}\right )}} + \frac {2 \, x^{2} e^{\left (2 i \, a\right )} \log \left (x^{2} + e^{\left (2 i \, a\right )}\right )}{x^{2} + \frac {e^{\left (4 i \, a\right )}}{x^{2}} + 2 \, e^{\left (2 i \, a\right )}} - \frac {5 \, x^{2} e^{\left (2 i \, a\right )}}{2 \, {\left (x^{2} + \frac {e^{\left (4 i \, a\right )}}{x^{2}} + 2 \, e^{\left (2 i \, a\right )}\right )}} + \frac {4 \, e^{\left (4 i \, a\right )} \log \left (x^{2} + e^{\left (2 i \, a\right )}\right )}{x^{2} + \frac {e^{\left (4 i \, a\right )}}{x^{2}} + 2 \, e^{\left (2 i \, a\right )}} - \frac {3 \, e^{\left (4 i \, a\right )}}{2 \, {\left (x^{2} + \frac {e^{\left (4 i \, a\right )}}{x^{2}} + 2 \, e^{\left (2 i \, a\right )}\right )}} + \frac {2 \, e^{\left (6 i \, a\right )} \log \left (x^{2} + e^{\left (2 i \, a\right )}\right )}{{\left (x^{2} + \frac {e^{\left (4 i \, a\right )}}{x^{2}} + 2 \, e^{\left (2 i \, a\right )}\right )} x^{2}} + \frac {e^{\left (6 i \, a\right )}}{2 \, {\left (x^{2} + \frac {e^{\left (4 i \, a\right )}}{x^{2}} + 2 \, e^{\left (2 i \, a\right )}\right )} x^{2}} \]

[In]

integrate(x*tan(a+I*log(x))^2,x, algorithm="giac")

[Out]

-1/2*x^4/(x^2 + e^(4*I*a)/x^2 + 2*e^(2*I*a)) + 2*x^2*e^(2*I*a)*log(x^2 + e^(2*I*a))/(x^2 + e^(4*I*a)/x^2 + 2*e
^(2*I*a)) - 5/2*x^2*e^(2*I*a)/(x^2 + e^(4*I*a)/x^2 + 2*e^(2*I*a)) + 4*e^(4*I*a)*log(x^2 + e^(2*I*a))/(x^2 + e^
(4*I*a)/x^2 + 2*e^(2*I*a)) - 3/2*e^(4*I*a)/(x^2 + e^(4*I*a)/x^2 + 2*e^(2*I*a)) + 2*e^(6*I*a)*log(x^2 + e^(2*I*
a))/((x^2 + e^(4*I*a)/x^2 + 2*e^(2*I*a))*x^2) + 1/2*e^(6*I*a)/((x^2 + e^(4*I*a)/x^2 + 2*e^(2*I*a))*x^2)

Mupad [B] (verification not implemented)

Time = 28.09 (sec) , antiderivative size = 41, normalized size of antiderivative = 0.80 \[ \int x \tan ^2(a+i \log (x)) \, dx=\frac {2\,{\mathrm {e}}^{a\,4{}\mathrm {i}}}{x^2+{\mathrm {e}}^{a\,2{}\mathrm {i}}}+2\,{\mathrm {e}}^{a\,2{}\mathrm {i}}\,\ln \left (x^2+{\mathrm {e}}^{a\,2{}\mathrm {i}}\right )-\frac {x^2}{2} \]

[In]

int(x*tan(a + log(x)*1i)^2,x)

[Out]

(2*exp(a*4i))/(exp(a*2i) + x^2) + 2*exp(a*2i)*log(exp(a*2i) + x^2) - x^2/2